package com.yysoft.admin.dao;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;

import com.yysoft.admin.entity.Mastergroup;

@Repository
public class MastergroupDao extends HibernateDaoSupport{
	
	public void saveOrUpdate(Mastergroup entity){
		this.getHibernateTemplate().saveOrUpdate(entity);
	}
	
	public void delete(Mastergroup entity){
		this.getHibernateTemplate().delete(entity);
	}
	
	public List<Mastergroup> findByMasterId(String masterid){
		return this.getHibernateTemplate().find("from Mastergroup t1 where 2>1 and t1.masterid="+masterid);
	}
	
	public Mastergroup getMastergroupMG(String masterid,String groupid){
		StringBuffer sbSQL=new StringBuffer();
		sbSQL.append("from Mastergroup t1 where 2>1 ");
		sbSQL.append("and t1.masterid="+masterid+" ");
		sbSQL.append("and t1.groupid="+groupid+" ");
		List<Mastergroup> list = this.getHibernateTemplate().find(sbSQL.toString());
		if(null!=list&&list.size()>0){
			return list.get(0);
		}else{
			return null;
		}
	
	}

}
